/**
  * Element——元素
  * 1.元素是块中的组成部分。
  * 2.元素不能离开块来使用。
  * 3.BEM 不推荐在元素中嵌套其他元素。
  * 如.separator__element
  */
  @mixin e($element) {
    $E: $element-separator + $element !global;
    $selector: &;  // & 可以取到父选择器类名

    @if containSpecialLabel($selector) {
      $currentSelector: #{extractBlock($selector) + $element-separator + $element };

      @at-root #{$selector}{
        #{$currentSelector} {
          @content;
        }
      }
    }
    @else {
      @at-root &#{$E} {
        @content;
      }
    }
  }

  /**
    * Modifier——修饰符
    * 1.修饰符用来定义块或元素的外观和行为。
    * 2.同样的块或元素在应用不同的修饰符之后，会有不同的外观。
    * 如.separator__element--modifier
    */
  @mixin m($modifier) {
    $M: $modifier-separator + $modifier;

    @at-root #{&}#{$M} {
      @content;
    }
  }

  /**
    * is——状态判断
    * 如.separator.is-state
    */
  @mixin when($state) {
    $S: $state-prefix + $state;

    @at-root #{&}.#{$S} {
      @content;
    }
  }


@mixin clearfix {
  &:after {
    content: "";
    display: table;
    clear: both;
  }
}

@mixin scrollBar {
  &::-webkit-scrollbar-track-piece {
    background: #d3dce6;
  }
  &::-webkit-scrollbar {
    width: 6px;
  }
  &::-webkit-scrollbar-thumb {
    background: #99a9bf;
    border-radius: 20px;
  }
}

@mixin relative {
  position: relative;
  width: 100%;
  height: 100%;
}

@mixin pct($pct) {
  width: #{$pct};
  position: relative;
  margin: 0 auto;
}

@mixin triangle($width, $height, $color, $direction) {
  $width: $width/2;
  $color-border-style: $height solid $color;
  $transparent-border-style: $width solid transparent;
  height: 0;
  width: 0;
  @if $direction==up {
    border-bottom: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  }
  @else if $direction==right {
    border-left: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  }
  @else if $direction==down {
    border-top: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  }
  @else if $direction==left {
    border-right: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  }
}
